package com.antd.common.log.listener;

import com.antd.admin.api.entity.SysLog;
import com.antd.common.log.event.SysLogEvent;
import com.antd.common.log.fegin.RemoteLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;

/**
 * TODO
 *
 * @author 子丶沫
 * @version 1.0
 * @date 2020/11/18 18:03
 */
@Slf4j
public class SysLogListener {
    @Autowired
    private RemoteLogService remoteLogService;

    @Async
    @EventListener(SysLogEvent.class)
    public void saveLog(SysLogEvent event){
        SysLog sysLog=(SysLog)event.getSource();
        log.info("远程日志记录成功：{}", sysLog);
        remoteLogService.saveLog(sysLog);
    }
}
